package com.hl.sfzy.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hl.sfzy.constant.CommonConstant;
import com.hl.sfzy.entity.SysCompany;

import com.hl.sfzy.entity.SysEvaluate;
import com.hl.sfzy.mapper.SysEvaluateMapper;
import com.hl.sfzy.service.SysEvaluateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service("sysEvaluateService")
public class SysEvaluateServiceImpl implements SysEvaluateService {
    @Autowired
    private SysEvaluateMapper sysEvaluateMapper;
    @Override
    public int add(SysEvaluate entity) {
        return sysEvaluateMapper.insert(entity);
    }

    @Override
    public int edit(SysEvaluate entity) {
        return sysEvaluateMapper.update(entity);
    }

    @Override
    public int remove(Integer id) {
        return sysEvaluateMapper.delete(id);
    }

    @Override
    public int removeBatch(Integer[] ids) {
        return sysEvaluateMapper.deleteBatch(ids);
    }

    @Override
    public List<SysEvaluate> find(SysEvaluate entity) {
        return sysEvaluateMapper.select(entity);
    }

    @Override
    public SysEvaluate findById(Integer id) {
        return sysEvaluateMapper.selectById(id);
    }

    @Override
    public Map<String, Object> findPage(Integer pageNum, Integer pageSize, SysEvaluate entity) {
        //开启分页
        PageHelper.startPage(pageNum, pageSize);
        //当前页数据
        List<SysEvaluate> list = sysEvaluateMapper.select(entity);
        //分页信息对象
        PageInfo<SysEvaluate> pageInfo = new PageInfo<>(list);

        Map<String, Object> map = new HashMap<>();

        //map存储当前页数据、总页数、总记录数
        map.put(CommonConstant.PAGE_LIST,list);
        map.put(CommonConstant.PAGE_TOTAL,pageInfo.getPages());
        map.put(CommonConstant.TOTAL,pageInfo.getTotal());

        return map;
    }

    @Override
    public List<SysEvaluate> selectByconselorId(Integer id) {
        return sysEvaluateMapper.selectByconselorId(id);
    }

    @Override
    public List<SysEvaluate> selectLimit(Integer id) {
        return sysEvaluateMapper.selectLimit(id);
    }

    @Override
    public List<SysEvaluate> findbyStatus(Integer status) {
        return sysEvaluateMapper.byStatus(status);
    }


}
